package com.hmdp.ThreadUtil;/**
 * @Author:fengxiaohui
 * @Description:
 * @Date:Create in 11:00 上午 2023/6/10
 * @Modified By:
 */

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 *@Author:fengxiaohui
 *@Description:
 *@Date:Create in 11:00 上午 2023/6/10
 *@Modified By:
 */
@Slf4j
public class Lockdemo {

    public static void main(String[] args) {
        SaleTicketDemo02 ticket = new SaleTicketDemo02();
        Lock lock = new ReentrantLock();
        lock.lock();



    }

}

@Slf4j
class SaleTicketDemo02 {
    private  int num = 500;

    public synchronized void sale(){
        if (num > 0) {
            log.debug(Thread.currentThread().getName()+"--->卖出: "+(num--) +"    剩余票: "+num);
        }

    }
}
